using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _1VD02
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        class PhanSo
        {
            private int tu;
            private int mau;
            public PhanSo()
            {
                tu = 0;
                mau = 1;
            }
            public PhanSo(int tu, int mau)
            {
                this.tu = tu;
                this.mau = mau;
            }
            public string Chuoi()
            {
                string kq = tu + "/" + mau;
                return kq;
            }
            public PhanSo Tong(PhanSo P)
            {
                PhanSo kq = new PhanSo();
                kq.tu = tu * P.mau + mau * P.tu;
                kq.mau = mau * P.mau;
                return kq;
            }
            public PhanSo Hieu(PhanSo P)
            {
                PhanSo kq = new PhanSo();
                kq.tu = tu * P.mau - mau * P.tu;
                kq.mau = mau * P.mau;
                return kq;
            }
            public PhanSo Tich(PhanSo P)
            {
                PhanSo kq = new PhanSo();
                kq.tu = tu * P.tu;
                kq.mau = mau * P.mau;
                return kq;
            }
            public PhanSo Thuong(PhanSo P)
            {
                PhanSo kq = new PhanSo();
                kq.tu = tu * P.mau;
                kq.mau = mau * P.tu;
                return kq;
            }
        }

        private void btnCong_Click(object sender, EventArgs e)
        {
            int tu1 = int.Parse(txtTu1.Text);
            int mau1 = int.Parse(txtMau1.Text);
            int tu2 = int.Parse(txtTu2.Text);
            int mau2 = int.Parse(txtMau2.Text);
            PhanSo ps1 = new PhanSo(tu1, mau1);
            PhanSo ps2 = new PhanSo(tu2, mau2);
            PhanSo kq = ps1.Tong(ps2);
                txtKetQua.Text = kq.Chuoi();
        }

        private void btnTru_Click(object sender, EventArgs e)
        {
            int tu1 = int.Parse(txtTu1.Text);
            int mau1 = int.Parse(txtMau1.Text);
            int tu2 = int.Parse(txtTu2.Text);
            int mau2 = int.Parse(txtMau2.Text);
            PhanSo ps1 = new PhanSo(tu1, mau1);
            PhanSo ps2 = new PhanSo(tu2, mau2);
            PhanSo kq = ps1.Hieu(ps2);
                txtKetQua.Text = kq.Chuoi();
        }

        private void btnNhan_Click(object sender, EventArgs e)
        {
            int tu1 = int.Parse(txtTu1.Text);
            int mau1 = int.Parse(txtMau1.Text);
            int tu2 = int.Parse(txtTu2.Text);
            int mau2 = int.Parse(txtMau2.Text);
            PhanSo ps1 = new PhanSo(tu1, mau1);
            PhanSo ps2 = new PhanSo(tu2, mau2);
            PhanSo kq = ps1.Tich(ps2);
                txtKetQua.Text = kq.Chuoi();
        }

        private void btnChia_Click(object sender, EventArgs e)
        {
            int tu1 = int.Parse(txtTu1.Text);
            int mau1 = int.Parse(txtMau1.Text);
            int tu2 = int.Parse(txtTu2.Text);
            int mau2 = int.Parse(txtMau2.Text);
            PhanSo ps1 = new PhanSo(tu1, mau1);
            PhanSo ps2 = new PhanSo(tu2, mau2);
            PhanSo kq = ps1.Thuong(ps2);
                txtKetQua.Text = kq.Chuoi();
        }
            }

}